class EventBus{
      public lists:{}
      public instance:EventBus | null
      constructor(){
         this.lists={}; 
      }
      on(type,handle){
          if(!this.lists[type]){
            this.lists[type] = [handle];
          }else{
            this.lists[type].push(handle) 
          }
      }
      emit(type,payload){ 
          if(this.lists[type]){
            this.lists[type].map(item=>item.call(this,payload))
          } 
      }
      getInstance(){
        // 单列，1为了优化性能，2避免多次创建 实例逻辑不通顺问题
          if(!this?.instance){
               this.instance =  new EventBus()
          }
          return this.instance;
      }
}

export default new EventBus().getInstance();